/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.ucb.game8numbers.service;

import br.com.ucb.game8numbers.observer.DataResponsibleObserver;
import br.com.ucb.game8numbers.observer.subject.DataResponsibleSubject;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author JessicaLuanne
 */
public class DataResponsible implements DataResponsibleSubject{

    private List<DataResponsibleObserver> observers;
    private String[][] values;
    private Integer movementQuantity;

    public DataResponsible() {
        observers = new ArrayList<DataResponsibleObserver>();
        this.movementQuantity = 0;
    }

    public DataResponsible(String[][] values) {
        observers = new ArrayList<DataResponsibleObserver>();
        this.values = values;
        this.movementQuantity = 0;
    }

    public void changeDataResponsible(String[][] values, int movementQuantity)
    {
        this.values = values;
        this.movementQuantity = movementQuantity;
        notifyObservers();
    }

    @Override
    public void registerObserver(DataResponsibleObserver o) {
        observers.add(o);
    }

    @Override
    public void removeObserver(DataResponsibleObserver o) {
        observers.remove(o);
    }

    @Override
    public void notifyObservers() {
        for (DataResponsibleObserver observer : observers) {
            observer.update(values, movementQuantity);
        }
    }

    public Integer getMovimentQuantity() {
        return movementQuantity;
    }

    public void setMovimentQuantity(Integer movementQuantity) {
        this.movementQuantity = movementQuantity;
    }

    public String[][] getValues() {
        return values;
    }

    public void setValues(String[][] values) {
        this.values = values;
    }
    public void notifyEndGame(){
        for (DataResponsibleObserver observer : observers) {
            observer.endGameMessage();
        }
    }
}
